import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
// 2. 配置路由
const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: '/home',

  },
  {
    path: "/home",
    component: () => import("@/view/home/index.vue"),
  },
  {
    path: "/hospitaldetails",
    component: () => import("@/view/hospitaldetails/index.vue"),
    children: [
      {
        path: "register",
        component: () => import("@/view/hospitaldetails/components/register.vue"),
        meta: {
          title: "预约挂号",
        },
      },
      {
        path: "detail",
        component: () => import("@/view/hospitaldetails/components/detail.vue"),
        meta: {
          title: "医院详情",
        },
      },
      {
        path: "notice",
        component: () => import("@/view/hospitaldetails/components/notice.vue"),
        meta: {
          title: "预约通知",
        },
      },
      {
        path: "close",
        component: () => import("@/view/hospitaldetails/components/close.vue"),
        meta: {
          title: "停诊信息",
        },
      },
      {
        path: "search",
        component: () => import("@/view/hospitaldetails/components/search.vue"),
        meta: {
          title: "查询",
        },
      },
      {
        path: "register_step1",
        component: () => import("@/view/hospitaldetails/components/register_step1.vue"),
      },
      {
        path: "register_step2",
        component: () => import("@/view/hospitaldetails/components/register_step2.vue"),
      },
    ],
  },

];
// 1.返回一个 router 实列，为函数，里面有配置项（对象） history
const router = createRouter({
  history: createWebHistory(),
  routes,
  // 每次切换路由页面滚动到顶部
  scrollBehavior () {
      return {
      left: 0,
      top: 0,
    };
  }
});

// 3导出路由   然后去 main.ts 注册 router.ts
export default router